package main

import "fmt"

func main() {
	numbers := make([]int, 3, 5)
	printSlice(numbers)
	/* 空切片 */
	var nums []int
	printSlice(nums)
	/* 切片截取 */
	arr := []int{0, 1, 2, 3, 4, 5, 6, 7, 8}
	printSlice(arr)
	fmt.Println("截取1-4：", arr[1:4])
	fmt.Println("截取到3：", arr[:3])
	fmt.Println("从4开始截取：", arr[4:])
}

func printSlice(x []int) {
	fmt.Printf("len=%d cap=%d slice=%v\n", len(x), cap(x), x)
}
